import 'package:flutter_eve_plugin/store/base_action.dart';
import 'package:flutter_eve_plugin/store/ye_xiu/archives/main.dart';
import 'package:flutter_eve_plugin/utils/print_util.dart';
import 'package:redux/redux.dart';
import 'constant.dart';

ArchievesState archievesReducer(ArchievesState state, action) {
  if (!(action is BaseAction)) {
    return state;
  }
  BaseAction baseAction = action;
  switch (baseAction.type) {
    case YX_ACHIEVES_ROLE:
      return state.copyWith(achivevesRoleEntity: baseAction.data);
    case YX_ACHIEVES_WEAPON:
      return state.copyWith(achievesWeaponEntity: baseAction.data);
    case YX_ACHIEVES_FORM:
      return state.copyWith(achievesFormEntity: baseAction.data);
    case YX_PERSON_DATA:
      logPrint('ArchievesAbilityEntity data - $baseAction.data');
      return state.copyWith(archievesAbilityEntity: baseAction.data);
    case YX_ABILITY_DETAIL:
      return state.copyWith(abilityDetailEntity: baseAction.data);
  }
  return state;
}

// ignore: non_constant_identifier_names
final AchievesReducer = combineReducers<ArchievesState>([archievesReducer]);

